<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateProductStocksTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('product_stocks', function (Blueprint $table) {
            $table->increments('id');
            $table->integer('product_id')->unsigned()->index()->default(0)->comment('商品ID');
            $table->integer('storage_id')->unsigned()->default(0)->comment('仓库ID');
            $table->integer('num')->unsigned()->default(0)->comment('库存数量');
            $table->decimal('cost_price',8,2)->unsigned()->default(0.00)->comment('成本单价');
            $table->decimal('total_cost_price',8,2)->unsigned()->default(0.00)->comment('成本总价');

            $table->timestamps();
        });
        \DB::statement("ALTER TABLE `product_stocks` comment '库存表'");

    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('product_stocks');
    }
}
